#!/usr/bin/perl -w
use strict;
use Getopt::Long;

#88888888888888888888888888888888888888888888888888888888888888888888888888888888

#	Usage

#88888888888888888888888888888888888888888888888888888888888888888888888888888888

my $cmd = <<"Bourne ShellCMD";
	test_merge_unique
		< test.txt
		test/unit_test.pl
Bourne ShellCMD

sub prepare_cmd
{
	#remove beginning white space and new lines
	$_[0] =~tr/\t\n/ /d;
	$_[0] =~ s/\s+/ /gm;
	if ($_[1])
	{
		print STDERR $_[0], "\n";
	}
}

sub run_cmd
{
	prepare_cmd(@_);
	return `$_[0]`;
}

#
#	print input data
#
{
	open(DATAOUT,  ">test.txt") or die;
	while (<DATA>)
	{
		print DATAOUT $_;
	}
	close DATAOUT;
}

my $result = run_cmd($cmd);
if ($result ne "2\taPPle\n3\tcrumble\n2\toranges\n3\tpears\n")
{
	print STDERR "FAILED\n";
}
else
{
	print STDERR "SUCCESS!!!\n";
}



__DATA__
aPPle
apple
oranges
ORANGES
pears
PEARS
crumble
CRUMBLE
crUMBLe
peaRS